﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GLEED2D.src.Forms
{
    public partial class AddBox2DProperty : Form
    {
        public CustomProperty cp = new CustomProperty();

        SerializableDictionary customproperties;

        public AddBox2DProperty(SerializableDictionary currentproperties)
        {
            InitializeComponent();
            customproperties = currentproperties;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            AddCustomPropertyToDictionary("Mass", numericMass.Value.ToString(), "Mass");
            AddCustomPropertyToDictionary("LinearDamping", numericLinearDamping.Value.ToString(), "LinearDamping");
            AddCustomPropertyToDictionary("Friction", numericFriction.Value.ToString(), "Friction");
            AddCustomPropertyToDictionary("Restitution", numericRestitution.Value.ToString(), "Restitution");
            AddCustomPropertyToDictionary("Density", numericDensity.Value.ToString(), "Density");

            AddCustomPropertyToDictionary("StaticBody", btnStatic.Checked, "Body Type");
        }

        private void AddCustomPropertyToDictionary(string name, string value, string description)
        {
            CustomProperty cp = new CustomProperty();
            cp.name = name;
            cp.value = value;
            cp.description = description;
            cp.type = typeof(string);
            customproperties[cp.name] = cp;
        }

        private void AddCustomPropertyToDictionary(string name, bool value, string description)
        {
            CustomProperty cp = new CustomProperty();
            cp.name = name;
            cp.value = value;
            cp.description = description;
            cp.type = typeof(bool);
            customproperties[cp.name] = cp;
        }
    }
}
